package com.wkbb.basic.thread;

import com.wkbb.basic.enums.YouTuOperateTypeEnum;
import com.wkbb.basic.service.YouTuService;
import com.wkbb.basic.utils.ImageOfbase64UtilDto;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 优图操作异步处理
 * */
@Slf4j
public class YouTuTask implements Runnable {

    private Integer operateType;
    private YouTuService youTuService;
    private Long accountId;
    private Long orgId;
    private Long userId;
    private String personId;
    private ImageOfbase64UtilDto imageOfbase64UtilDtoOne;
    private List<ImageOfbase64UtilDto> imagesList;
    private Integer type;
    private Short similar;

    public YouTuTask(Integer operateType,YouTuService youTuService,Long accountId, Long orgId, Long userId,String personId,ImageOfbase64UtilDto imageOfbase64UtilDtoOne,List<ImageOfbase64UtilDto> imagesList, Integer type,Short similar) {
        this.youTuService = youTuService;
        this.operateType = operateType;
        this.accountId = accountId;
        this.orgId = orgId;
        this.userId = userId;
        this.personId = personId;
        this.imageOfbase64UtilDtoOne = imageOfbase64UtilDtoOne;
        this.imagesList = imagesList;
        this.type = type;
        this.similar = similar;
    }

    @Override
    public void run() {
        try {
            log.info("进入优图操作异步处理.....start，orgId:{}，userId:{}", orgId, userId);
            Thread.sleep(1000);
            if(operateType == YouTuOperateTypeEnum.YOU_TU_OPERATE_ADD_PERSON.getCode().intValue())
            {
                log.info("******YouTuTask addPerson begin****");
                youTuService.addPerson(orgId, personId, imageOfbase64UtilDtoOne, accountId, userId);
                log.info("******YouTuTask addPerson end****");
            }
            else if(operateType == YouTuOperateTypeEnum.YOU_TU_OPERATE_DELETE_PERSON.getCode().intValue())
            {
                log.info("******YouTuTask deletePerson begin****");
                youTuService.deletePerson(orgId, userId);
                log.info("******YouTuTask deletePerson end****");
            }
            else if(operateType == YouTuOperateTypeEnum.YOU_TU_OPERATE_ADD_FACE.getCode().intValue())
            {
                log.info("******YouTuTask addFace begin****");
                youTuService.addFace(imagesList, personId, orgId, userId,type,similar);
                log.info("******YouTuTask addFace end****");
            }
            else if(operateType == YouTuOperateTypeEnum.YOU_TU_OPERATE_DELETE_FACE.getCode().intValue())
            {
                log.info("******YouTuTask deleteFace begin****");
                youTuService.deleteFace( personId, orgId);
                log.info("******YouTuTask deleteFace end****");
            }
            else if(operateType == YouTuOperateTypeEnum.YOU_TU_OPERATE_ADD_USER_FACE.getCode().intValue())
            {
                log.info("******YouTuTask addUserFace begin****");
                youTuService.addUserFace(imageOfbase64UtilDtoOne, personId, orgId, accountId, userId);
                log.info("******YouTuTask addUserFace end****");
            }
            log.info("进入优图操作异步处理.....end");
        } catch (Exception e) {
            log.error("优图操作异步处理，{}", e.getMessage());
            e.printStackTrace();
        }
    }
}
